package router

import (
	"fairysunny.com/gin-example/controller"
	"fairysunny.com/gin-example/middleware"
	"github.com/gin-gonic/gin"
)

func InitRouter(r *gin.Engine) {
	r.GET("/user", controller.GetLoginStatus)
	r.POST("/user", controller.Login)
	r.POST("/user/reg", controller.Register)
	r.DELETE("/user", controller.Logout)

	r.POST("/post", middleware.CheckRole(1), controller.CreatePost)
	r.DELETE("/post/:id", middleware.CheckRole(1), controller.DeletePost)
	r.PUT("/post", middleware.CheckRole(1), controller.UpdatePost)
	r.GET("/post/:id", middleware.CheckRole(1), controller.GetPost)
	r.GET("/posts", middleware.CheckRole(1), controller.GetAllPosts)
}
